home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / arevsnak.zip / SNAKE.SUB < prev   
Text File  |  1991-12-16  |  3KB  |  1 lines

  1. SUBROUTINE SNAKE.SUB(TEXT, MONITOR, DELAY)■*■* Snake■* (C) Copyright 1991, David A. Kirk■*■* David A. Kirk■* K-Tek, Inc■* 6305 Thornridge Dr.■* Grand Blanc, MI  48439■* CIS: 70233,3465■*■* This subroutine will, when called, clear the screen, turn the cursor off,■* and then use the string in TEXT as a snake that wanders around the screen.■* The routine will continue until a key is pressed. When coupled to the■* indexing routine, it will make a great screen saver (my motivation) but this■* part has not been completed. Snake.Sub needs to be cataloged.■*■* An integer (DELAY) can be used to slow the snake on fast machines■*■*    Text = Character string to use as the snake■* Monitor = "C" for a CGA, null or anything else for Monochrome/EGA/VGA■*   Delay = Integer representing a timing delay, 0 for no delay■*■* Version 1.0 - Released December 16, 1991 - David Kirk■■DECLARE SUBROUTINE VIDEO.RW, CATALYST■EQUATE CT TO "(C) Copyright 1991, David A. Kirk"■■R = ""■KEY = ""■DIR = 4■TEXT = " ":TEXT:" "■IMAGE = ""■■* Turn the cursor to green.■PRINT CHAR(27):"C":CHAR(0):CHAR(2)■■* Fill the array with the contents of TEXT■LENGTH = LEN(TEXT)■FOR X = 1 TO LENGTH■  R<X> = TEXT[X,1]:@VM:25+X:@VM:10■NEXT X■■@STATUS.ON = 0■@CRTHIGH = @CRTMAXHIGH■HEIGHT = @CRTHIGH-1■VIDEO.RW(0,0,@CRTWIDE-1,HEIGHT,'R',IMAGE)■VIDEO.RW(0,0,@CRTWIDE-1,HEIGHT,'C'," ":CHAR(2))■■* Turn the cursor off■MON1 = " "■MON2 = CHAR(13)■GOSUB CURSOR■■* Main loop■LOOP UNTIL KEY > ""■  BEGIN CASE■    CASE DIR=1;IF R<1,3>=0  THEN GOSUB DIRECTION ELSE GOSUB MOVE; R<1,3>=R<1,3>-1;GOSUB PAINT■    CASE DIR=2;IF R<1,2>=@CRTWIDE THEN GOSUB DIRECTION ELSE GOSUB MOVE; R<1,2>=R<1,2>+1;GOSUB PAINT■    CASE DIR=3;IF R<1,3>=HEIGHT THEN GOSUB DIRECTION ELSE GOSUB MOVE; R<1,3>=R<1,3>+1;GOSUB PAINT■    CASE DIR=4;IF R<1,2>=0  THEN GOSUB DIRECTION ELSE GOSUB MOVE; R<1,2>=R<1,2>-1;GOSUB PAINT■  END CASE■  IF RND(18) < 1 THEN GOSUB DIRECTION■  INPUT KEY, -1■REPEAT■VIDEO.RW(0,0,@CRTWIDE-1,HEIGHT,'W',IMAGE)■@STATUS.ON = 1■@CRTHIGH = @CRTMAXHIGH - 3■IF MONITOR = "C" THEN■  MON1 = CHAR(6)■  MON2 = CHAR(7)■END ELSE■  MON1 = CHAR(12)■  MON2 = CHAR(13)■END■GOSUB CURSOR■STOP■■* Move the snake from the old location to the new■MOVE:■FOR Z = LENGTH TO 2 STEP -1■  R<Z,2>=R<Z-1,2>■  R<Z,3>=R<Z-1,3>■NEXT Z■RETURN■■* Draw the snake to the screen■PAINT:■FOR Z = 1 TO LENGTH■  PRINT @(R<Z,2>,R<Z,3>):R<Z,1>:■NEXT Z■IF DELAY > 0 THEN■  FOR Z = 1 TO DELAY■  NEXT Z■END■RETURN■■* Change the direction■DIRECTION:■LOOP■  X = RND(4)+1■UNTIL X <> DIR■REPEAT■DIR = X■RETURN■■CURSOR:■  CATALYST("CV",CHAR(2):STR(CHAR(0),9):"┤":CHAR(1):"╣":MON2:MON1:"═":CHAR(16):"╦")■RETURN